<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>无标题文档</title>
    <link href="<%=path%>/css/style.css" rel="stylesheet" type="text/css"/>
    <link href="<%=path%>/css/select.css" rel="stylesheet" type="text/css"/>
    <link href="<%=path%>/css/bootstrap.min.css" rel="stylesheet" type="text/css">
    <script type="text/javascript" src="<%=path%>/js/jquery.min.js"></script>
    <script type="text/javascript" src="<%=path%>/js/select-ui.min.js"></script>
    <script type="text/javascript">
        function deletes(id) {
            window.location.href = "<%=basePath%>deleteDoctor?docId="+id;
        }

        function modify(id) {
            window.location.href = "<%=basePath%>getDoctorId?docId="+id;
        }
        function chgPageSize(size){
            document.forms[0].action="<%=basePath%>findSomeDoctors?pageNo=1&pageSize="+size;
            document.forms[0].submit();
            return false;
        }
        function goPage(pageNo){
            if(pageNo<1){
                return false;
            }
            if(pageNo>${list.pageCount}){
                return false;
            }
            document.forms[0].action="<%=basePath%>findSomeDoctors?pageSize=${list.pageSize}&pageNo="+pageNo;
            document.forms[0].submit();
            return false;
        }

        $(function () {
            $('tbody tr:odd').addClass("trLight");
            $(".select-all").click(function () {
                if ($(this).attr("checked")) {
                    $(".checkBox input[type=checkbox]").each(function () {
                        $(this).attr("checked", true);
                    });
                } else {
                    $(".checkBox input[type=checkbox]").each(function () {
                        $(this).attr("checked", false);
                    });
                }
            });
        });
    </script>
    <style type="text/css">
        body {
            background: #FFF
        }
    </style>
</head>

<body>
<div id="contentWrap">
    <!--表格控件 -->
    <div id="widget table-widget">
        <div class="pageTitle">医生管理</div>
        <div class="querybody">
            <form action="<%=basePath%>findSomeDoctors" method="post">
                <ul class="seachform">
                    <li><label>医生ID</label><input name="docId" type="text" class="scinput"/></li>
                    <li><label>医生名称</label><input name="realName" type="text" class="scinput"/></li>
                    <li><label>科室</label>  <!-- 从数据库科室表里面查询出科室id和科室名称，组合成下拉框 -->
                        <select style="width:150px;height:32px;" name="departId">
                            <option value="" >请选择</option>
                            <option value="2">外科</option>
                            <option value="1">内科</option>
                            <option value="3">神经科</option>
                            <option value="4">心脏科</option>
                        </select>
                    </li>
                    <li><label>&nbsp;</label><input name="" type="submit" class="scbtn" value="查询"/></li>
                </ul>
            </form>
        </div>
        <div class="pageColumn">
            <div class="pageButton"><a href="<%=path%>/html/ysadd.jsp"><img src="<%=path%>/images/t01.png" title="新增"/></a><span>医生列表</span>
            </div>
            <table>
                <thead>
                <th width="">医生ID</th>
                <th width="">医生名</th>
                <th width="">密码</th>
                <th width="">真实姓名</th>
                <th width="">所属科室</th>
                <th width="">职称</th>
                <th width="">联系电话</th>
                <th width="">年龄</th>
                <th width="">性别</th>
                <th width="">家庭住址</th>
                <th width="10%">操作</th>
                </thead>
                <tbody>
                <c:forEach items="${list.list}" var="doctor">
                    <tr>
                        <td>${doctor.docId}</td>
                        <td>${doctor.name}</td>
                        <td>${doctor.password}</td>
                        <td>${doctor.realName}</td>
                        <td>${doctor.department}</td>
                        <td>${doctor.positional}</td>
                        <td>${doctor.tel}</td>
                        <td>${doctor.age}</td>
                        <td>${doctor.sex}</td>
                        <td>${doctor.address}</td>
                        <td>
                            <a onclick="modify(${doctor.docId})"><img src="<%=path%>/images/icon/edit.png" width="16"
                                                         height="16"/></a>
                            <a onclick="deletes(${doctor.docId})"><img src="<%=path%>/images/icon/del.png" width="16"
                                                          height="16"/></a>
                        </td>
                    </tr>
                </c:forEach>

                </tbody>
            </table>
        </div>
    </div><!-- #widget -->
    <div id="pagination" style="align:right;margin-top:-10px;">
        <div id='project_pagination' class="pagination pagination-centered">
            <div class="pagination">
                <ul>
                    <li ><a href="javascript:goPage(${list.pageNo-1})">«</a></li>
                    <c:forEach begin="${list.pageNo-2<1?1:list.pageNo-2}" end="${list.pageNo+2}" var="cnt">
                        <c:if test="${cnt>=1 and cnt<=list.pageCount}">
                            <li class="${cnt==list.pageNo?'active':''}"><a href="javascript:goPage(${cnt})">${cnt}</a></li>
                        </c:if>
                    </c:forEach>


                    <li><a href="javascript:goPage(${list.pageNo+1})">»</a></li>
                </ul>
                <ul>
                    <li><span>(${list.firstResult+1}-${list.firstResult+list.pageSize>list.rowCount?list.rowCount:list.firstResult+list.pageSize}/${list.rowCount})</span></li>
                    <li><span>显示条数&nbsp;:&nbsp;</span></li>
                </ul>
                <ul>
                    <li class="${list.pageSize==2?'active':''}"><a href="javascript:chgPageSize(2)">2</a></li>
                    <li class="${list.pageSize==30?'active':''}"><a href="javascript:chgPageSize(30)">30</a></li>
                    <li class="${list.pageSize==50?'active':''}"><a href="javascript:chgPageSize(50)">50</a></li>
                </ul>
            </div>
        </div>
    </div>
</div>
</body>
</html>
